import React, { useState } from 'react'
import { Table } from 'antd'
function useBasicTable2() {
  const [pagnationPage] = useState('bottomCenter') //改成BottomCenter
  const [selectionType] = useState('checkbox') //checkbox
  //列数据
  const columns = [
    {
      title: '姓名',
      width: 100, //不写就自适应
      dataIndex: 'name', //列对应的数据名称
      render: (text) => <div>{text}</div>,
    },
    {
      title: '资产',
      width: 100, //不写就自适应
      className: 'column-money',
      dataIndex: 'money', //列对应的数据名称
      align: 'center', //right center,left
    },
    {
      title: '地址',
      dataIndex: 'address', //列对应的数据名称
    },
  ]
  //数据
  const data = [
    {
      key: '1',
      name: '张三',
      money: '$300,000.00',
      address: 'New York No. 1 Lake Park',
    },
    {
      key: '2',
      name: '李四',
      money: '$1,256,000.00',
      address: 'London No. 1 Lake Park',
    },
    {
      key: '3',
      name: '王五',
      money: '$120,000.00',
      address: 'Sidney No. 1 Lake Park',
    },
  ]
  //Header
  const HeaderData = () => {
    return <div classsname="Footer">这就是头部222</div>
  }
  //Footer
  const FooterData = () => {
    return <div classsname="Footer">这就是尾巴</div>
  }
  //分页
  const handleClick = (current, pageSize) => {
    console.log(current, pageSize)
    console.log(`当前页是${current}`)
    console.log(`每页条数${pageSize}`)
  }
  //checkbox 选择
  const rowSelection = {
    onChange: (selectedRowKeys, selectedRows) => {
      console.log(
        `selectedRowKeys: ${selectedRowKeys}`,
        'selectedRows: ',
        selectedRows
      )
    },
    getCheckboxProps: (record) => ({
      disabled: record.name === '张三', // Column configuration not to be checked
      name: record.name,
    }),
  }

  return (
    <Table
      rowSelection={{
        type: selectionType,
        ...rowSelection,
      }}
      columns={columns}
      dataSource={data}
      bordered
      title={HeaderData}
      footer={FooterData}
      pagination={{
        position: [pagnationPage],
        defaultCurrent: 1,
        defaultPageSize: 2,
        total: 50,
        onChange: handleClick,
      }}
    />
  )
}

export default useBasicTable2
